package com.xucy.springboot;

import com.xucy.springboot.netty.listener.NettyServerListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

@SpringBootApplication
@MapperScan(value = "com.xucy.springboot.dao")
public class JpaApplication implements ApplicationContextAware {

    @Autowired
    private NettyServerListener nettyServerListener;

    public static void main(String[] args) {
        SpringApplication.run(JpaApplication.class, args);
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    nettyServerListener.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }
}
